<template>
	<div>
		<ul class="mui-table-view mui-table-view-chevron">
			<li class="mui-table-view-cell mui-media" v-for="item in newlist" :key="item.id">
				<router-link :to="'/home/newsinfo/'+item.id">
					<img class="mui-media-object mui-pull-left" :src="item.img_url">
					<div class="mui-media-body">
						<h2>{{item.title}}</h2>
						<p class='mui-ellipsis'>
							<span>发布时间: {{item.add_time | dataFormt }}</span>
							<span>点击:{{item.click}}次</span>
						</p>
					</div>
				</router-link>
			</li>
		</ul>
	</div>
</template>

<script>
	import {Toast} from 'mint-ui'
	
	export default{
		data (){
			return {
				newlist:[] //新闻列表
			}
		},
		created(){
			this.getNewList()
		},
		methods:{
			getNewList(){
				this.axios.get('/home/newlist')
					.then(res =>{
						var callback=res.data
						if(callback.err_code === 0){
							Toast('获取new成功')
							console.log(callback)
							this.newlist=callback.newlists
						}else{
							Toast('获取失败')
						}
					})
					.catch(function(err){
						Toast('获取失败')
					})
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	.mui-table-view{
		li{
			h2{
				font-size: 14px;
			}
			.mui-ellipsis{
				font-size:12px;
				color:dodgerblue;
				display: flex;
				justify-content: space-around;
			}
		}
		.mui-table-view-cell{
			padding-right: 35px;
		}
	}
</style>
